<template>
	<view>
		<block v-if="user==''">
			<normal-index :ivcodedf="ivcode1"></normal-index>
		</block>
		<block v-else>
			<login-index></login-index>
		</block>
		<u-tabbar :value="value" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true" activeColor="#C62B2C"
			inactiveColor="#707070">
			<u-tabbar-item text="首页" @click="clickBar1" name="bar1">
				<image class="u-page__item__slot-icon" slot="active-icon"
					src="../../../static/img/tabbar/homeactive.png">
				</image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="../../../static/img/tabbar/home.png">
				</image>
			</u-tabbar-item>
			<u-tabbar-item text="发布" @click="clickBar2" name="bar2">
				<image class="u-page__item__slot-icon" slot="active-icon"
					src="../../../static/img/tabbar/publishactive.png">
				</image>
				<image class="u-page__item__slot-icon" slot="inactive-icon"
					src="../../../static/img/tabbar/publish.png">
				</image>
			</u-tabbar-item>
			<u-tabbar-item text="动态" @click="clickBar3" v-if="showXt" name="bar3">
				<image class="u-page__item__slot-icon" slot="active-icon"
					src="../../../static/img/tabbar/courseactive.png">
				</image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="../../../static/img/tabbar/course.png">
				</image>
			</u-tabbar-item>
			<u-tabbar-item text="收益" @click="clickBar5" name="bar5">
				<image class="u-page__item__slot-icon" slot="active-icon"
					src="../../../static/img/tabbar/incomeactive.png">
				</image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="../../../static/img/tabbar/income.png">
				</image>
			</u-tabbar-item>
			<u-tabbar-item text="我的" @click="clickBar4" name="bar4">
				<image class="u-page__item__slot-icon" slot="active-icon"
					src="../../../static/img/tabbar/mineactive.png">
				</image>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="../../../static/img/tabbar/mine.png">
				</image>
			</u-tabbar-item>
		</u-tabbar>

		<!-- <m-login ref="login" :zIndex="1000000000" @success="loginRes" @error="loginError"></m-login> -->
	</view>
</template>

<script>
	import {
		getConfig
	} from '@/config/api.js'

	export default {
		data() {
			return {
				user: uni.getStorageSync('UserInfo', null),
				value: 'bar1',
				showXt: false,
				ivcode1: ""
			}
		},
		onLoad(op) {
			console.log("ivcode", op.ivcode)
			if (op.ivcode) {
				this.ivcode1 = op.ivcode;
				uni.setStorageSync('ivcode', op.ivcode);
			} else {
				this.ivcode1 = uni.getStorageSync('ivcode', '');
			}
		},
		onShow() {
			this.getcofg();
			this.user = uni.getStorageSync('UserInfo', '')
		},
		methods: {
			getcofg() {
				getConfig().then(res => {
					if (res.value == 1) {
						this.showXt = true
					} else {
						this.showXt = false
					}
				})
			},
			// loginRes() {
			// 	this.user = uni.getStorageSync('UserInfo');
			// },
			// loginError(err) {
			// },
			// checkLogin() {
			// 	this.$refs.login.checkLogin();
			// },
			onPageScroll(e) {
				uni.$emit('onPageScroll', e); //传递参数
			},
			onReachBottom(e) {
				uni.$emit('onReachBottom', e); //传递参数
			},
			onPullDownRefresh(e) {
				uni.stopPullDownRefresh();
			},
			clickBar1() {
				// this.value = 'bar1';
				uni.switchTab({
					url: '/pages/tabbar/tabbar-1/tabbar-1'
				})
			},
			clickBar2() {
				// this.value = 'bar2';
				uni.switchTab({
					url: '/pages/tabbar/tabbar-2/tabbar-2'
				})
			},
			clickBar3() {
				// this.value = 'bar3';
				uni.switchTab({
					url: '/pages/tabbar/tabbar-3/tabbar-3'
				})
			},
			clickBar4() {
				// this.value = 'bar4';
				uni.switchTab({
					url: '/pages/tabbar/tabbar-4/tabbar-4'
				})
			},
			clickBar5() {
				// this.value = 'bar4';
				uni.switchTab({
					url: '/pages/center/income'
				})
			},
		}
	}
</script>

<style scoped>
	.u-page__item__slot-icon {
		width: 40rpx;
		height: 40rpx;
	}

	/deep/ .uni-popup__wrapper.center {
		width: 80%;
		border-radius: 20rpx;
	}
</style>
